package com.example.forum.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.forum.MyQuery;
import com.example.forum.entity.TUserroles;
import com.example.forum.mapper.TUserrolesMapper;
import com.example.forum.service.ITUserrolesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author why
 * @since 2019-10-30
 */
@Service
public class TUserrolesServiceImpl extends ServiceImpl<TUserrolesMapper, TUserroles> implements ITUserrolesService {
    @Autowired
    TUserrolesMapper userrolesMapper;

    @Override
    public List<String> getUserRoles(String userId) {
        List<String> roleIds = userrolesMapper.selectList(
                new MyQuery<TUserroles>().select("RoleId").eq("UserId", userId)
        ).stream().map(TUserroles::getRoleid).collect(Collectors.toList());
        return roleIds;
    }
}
